package gui;

import gameEngine.*;
import java.awt.FlowLayout;
import javax.swing.JPanel;

/**
 * @author Wojciech Łopata
 *
 */

public class GameDrawer extends JPanel
{
	private static final long serialVersionUID = -5696642011575031709L;

	private final BoardDrawer boardDrawer;
	private final GameInfoPanel infoPanel;
	private GameInfo info;

	public GameDrawer(BoardDrawer boardDrawer)
	{
		this.boardDrawer = boardDrawer;
		infoPanel = new GameInfoPanel();
		
		setLayout(new FlowLayout());
		
		add(boardDrawer);
		add(infoPanel);
	}

	public void startDrawing(GameInfo info)
	{
		this.info = info;
		infoPanel.startDrawing(info);
	}
	
	public void stopDrawing()
	{
		boardDrawer.clean();
		infoPanel.stopDrawing();
	}
	
	public void update()
	{
		if(info == null) return;
		boardDrawer.update(info.getCurrentBoard());
		infoPanel.updatePanel();
	}
}
